package com.entity;

import java.util.ArrayList;
import java.util.List;

public class LanguageContext {
	private static int selectedLanguagePosition = 1;// Vietnamese
	private static List<Language> listLanguages = new ArrayList<Language>();

	/*
	 * add language to list
	 */
	public static void addLanguage(Language language) {
		listLanguages.add(language);
	}

	public static List<Language> getListLanguages() {
		return listLanguages;
	}

	public static Language getSelectedLanguage() {
		return listLanguages.get(selectedLanguagePosition);
	}

	public static void setSelectedLanguagePosition(int selectedLanguagePosition) {
		if (selectedLanguagePosition <= listLanguages.size() - 1)
			LanguageContext.selectedLanguagePosition = selectedLanguagePosition;
	}

	public static void changeLanguageCode(int pos, String code) {
		if (pos >= 0 && pos < listLanguages.size())
			listLanguages.get(pos).setLanguageCode(code);
	}
}
